var CommentCon = iClass.get("Comment");
var db = iClass.db;
iClass.method("Admin", {
	getCommentList: function(num, page) {
		var comment_list = db.find_all(CommentCon.dbname)

		//处理参数
		var total_num = comment_list.length;
		num = ~~num;
		num > 0 || (num = total_num); //num > 0
		page = ~~page;
		page >= 0 || (page = 0); //page >= 0
		var total_page = Math.ceil(total_num / num) || 1;
		//整理数据
		comment_list = comment_list.slice().reverse().page(num, page).map(function(comment_info) {
			return CommentCon.getInstance(comment_info).getDetail();
		});

		return {
			total_num: total_num,
			total_page: total_page,
			num: num,
			page: page,
			list: comment_list
		};
	},
	removeComment: function(comment_id) {
		var comment = CommentCon.get(comment_id);
		if (!comment) {
			Throw("找不到指定评论");
		}
		comment.remove();
	}
});